SRCS_C   := $(wildcard *.c)
SRCS_CPP := $(wildcard *.cc *.cpp)
TARGETS  := $(SRCS_C:.c=) $(basename $(SRCS_CPP))

CC      := gcc
CXX     := g++
COM_OP  := -Wall -g
RM      := rm -f

.PHONY: clean rebuild all

all: $(TARGETS)

# 编译C程序
% : %.c
	$(CC) $< -o $@ $(COM_OP)

# 编译C++程序
% : %.cc
	$(CXX) $< -o $@ $(COM_OP)

% : %.cpp
	$(CXX) $< -o $@ $(COM_OP)

clean:
	$(RM) $(TARGETS)

rebuild: clean all
